<template>
  <div id="aside" :class="{ 'collaps-mini': [true, 'immersive'].includes(collaps) }">
    <h1 class="logo">
      <img class="logo-default" v-if="!collaps" src="../../../assets/logo-white.png" />
      <img class="logo-mini" v-else src="../../../assets/logo-mini.png" />
    </h1>
    <div class="menu-wrap">
      <Menu />
    </div>
    <div class="collaps">
      <div @click="useSetCollaps">
        <i class="iconfont cp icon-zhankai"></i>
        <label>展开导航</label>
      </div>
    </div>
  </div>
  <div class="fixed-menu" :class="[{ open: isOpenImmersiveMenu }]" @mouseenter="useClearTimer" @mouseleave="useCloseImmersiveMenu">
    <Menu fixed />
  </div>
</template>
<script setup>
  import { computed } from "vue"
  import { useRouter } from "vue-router"
  import Menu from "./menu.vue"
  // hook
  import { useCollaps } from "@/hook/index"
  const router = useRouter()
  const { useClearTimer, useCloseImmersiveMenu, useIsOpenImmersiveMenu, useSetCollaps, useGetCollasp } = useCollaps()
  const collaps = computed(() => useGetCollasp())
  const isOpenImmersiveMenu = computed(() => useIsOpenImmersiveMenu())
  // 是否详情页面
  const isDetailedPage = () => {
    const currentRoute = router.currentRoute.value
    const isDetailed = currentRoute?.meta?.isDetailed
    console.log("isDetailed", isDetailed)
    isDetailed && useSetCollaps(2)
  }
  isDetailedPage()
</script>
<style lang="scss" scoped>
  #aside {
    height: 100%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #eee;
  }
  .menu-wrap {
    position: relative;
    flex: 1;
    height: 0;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .logo {
    padding: 16px 0 18px 24px;
    margin-bottom: 0;
    display: flex;
    align-items: center;
  }
  .logo-default {
    width: 118px;
  }
  .disabled-mask {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 10;
  }
  .collaps {
    display: flex;
    align-items: center;
    padding-left: 24px;
    height: 39px;
    border-top: 1px solid rgba(0, 0, 0, 0.2);
    color: var(--n-aside-collapse);
    div {
      cursor: pointer;
    }
    label {
      line-height: 1;
      margin-left: 8px;
      cursor: inherit;
    }
  }
  .collaps-mini {
    .collaps {
      padding-left: 0;
      justify-content: center;
      label {
        display: none;
      }
    }
  }
  .fixed-menu {
    position: fixed;
    // left: 0;
    left: -300px;
    top: 49px;
    bottom: 0;
    z-index: 1000000;
    width: 184px;
    background-color: var(--n-aside);
    border-right: 1px solid #ededed;
    transition: 0.3s;
    &.open {
      left: 0;
    }
  }
</style>
